package net.oschina.app.factory;


import android.os.Bundle;
import android.support.v4.app.Fragment;

import net.oschina.app.fragment.center_message.AtMeFragment;
import net.oschina.app.fragment.center_message.CommentsFragment;
import net.oschina.app.fragment.center_message.FansFragment;
import net.oschina.app.fragment.center_message.GoodsFragment;
import net.oschina.app.fragment.center_message.NewMessageFragment;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by wei03 on 2017/1/13.
 */

public class MessageFragmentFactory extends BaseFactory{
    public  Fragment getFragment(int position) {
        Map<Integer, Fragment> fragments = new HashMap<>();
        Fragment fragment = fragments.get(position);
        if (fragment == null) {
            switch (position) {
                case 0:
                    fragment = new AtMeFragment();
                    Bundle atMe = new Bundle();
                    atMe.putString("catalog","2");
                    fragment.setArguments(atMe);
                    break;
                case 1:
                    fragment = new CommentsFragment();
                    Bundle comments = new Bundle();
                    comments.putString("catalog","3");
                    fragment.setArguments(comments);
                    break;
                case 2:
                    fragment = new NewMessageFragment();
                    break;
                case 3:
                    fragment = new FansFragment();
                    Bundle fans = new Bundle();
                    fans.putString("relation","0");
                    fragment.setArguments(fans);
                    break;
                case 4:
                    fragment = new GoodsFragment();
                    break;
                default:
                    fragment = new AtMeFragment();
            }
            fragments.put(position, fragment);
        }
        return fragment;
    }
}
